﻿using System;
using System.Collections.Generic;
using System.Data;

using System.Text;
using System.Web.UI.WebControls;
using Module.Core.EntitiesInfo;
using Module.DataAccess;
using Module.EntitiesInfo;

namespace Module.BusinessLogic
{
  public class AdvertisementBL
    {
      public static int Insert(AdvertisementInfo advertisementInfo)
        {
            try
            {
                return new AdvertisementDB().Insert(advertisementInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

      public static void Update(AdvertisementInfo advertisementInfo)
        {
            try
            {
                new AdvertisementDB().Update(advertisementInfo);
            }
            catch (Exception ex)
            {
                throw;
            }

        }


      /// <summary>
      /// Delete a record from the Advertisement table.
      /// </summary>
      public static void Delete(int advertisementId)
      {
          try
          {
              new AdvertisementDB().Delete(advertisementId);
          }
          catch (Exception ex)
          {
              throw;
          }

      }
      public static DataTable GetAll()
      {
          try
          {
              return new AdvertisementDB().GetAll();
          }
          catch (Exception)
          {
              throw;
          }
      }
      /// <summary>
      /// Selects all records from the Advertisement table.
      /// </summary>
      public static CHRTList<AdvertisementInfo> SelectAll()
      {
          try
          {
              return new AdvertisementDB().SelectAll();
          }
          catch (Exception ex)
          {
              throw;
          }
      }

        public static List<AdvertisementInfo> Select(int type, string param_1, string param_2)
        {
            try
            {
                return ObjectHelper.FillCollection<AdvertisementInfo>(new AdvertisementDB().Select(type, param_1, param_2));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static List<AdvertisementInfo> Select(int type, string param_1)
        {
            try
            {
                return ObjectHelper.FillCollection<AdvertisementInfo>(new AdvertisementDB().Select(type, param_1));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static List<AdvertisementInfo> Select(int type)
        {
            try
            {
                return ObjectHelper.FillCollection<AdvertisementInfo>(new AdvertisementDB().Select(type));
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public static DataTable SelectTbl(int? type, string para_1, string para_2)
        {
            try
            {
                return new AdvertisementDB().SelectTbl(type, para_1, para_2);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public static DataTable SelectTbl(int? type, string para_1)
        {
            try
            {
                return new AdvertisementDB().SelectTbl(type, para_1);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static DataTable SelectTbl(int? type)
        {
            try
            {
                return new AdvertisementDB().SelectTbl(type);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        public static AdvertisementInfo GetInfo(int type, string para_1, string para_2)
        {
            try
            {
                AdvertisementInfo info;
                info = ObjectHelper.FillObject<AdvertisementInfo>(new AdvertisementDB().Select(type, para_1, para_2));
                if (info != null)
                    return info;
                return null;
            }
            catch (Exception)
            {
                throw;
            }
        }

        public static int GetCount(int positionID,int isEnable, DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow)
        {
            try
            {
                return new AdvertisementDB().GetCount(positionID,isEnable, starDatetime, endDatetime, beginRow, endRow);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static DataTable Search(int positionID,int isEnable,DateTime starDatetime, DateTime endDatetime, int beginRow, int endRow, string orderByColumn)
        {
            try
            {
                return new AdvertisementDB().Search(positionID,isEnable, starDatetime, endDatetime, beginRow, endRow, orderByColumn);
            }
            catch (Exception ex)
            {
                throw;
            }

        }
       
        public static void UpdateStatus(int advertisementID, int isEnable, int param)
        {
            try
            {
                new AdvertisementDB().UpdateStatus(advertisementID, isEnable, param);
            }
            catch (Exception ex)
            {
                throw;
            }

        }

        public static string GetMediaType(int mediaType)
        {
            string strMessage = "";
            if (mediaType == 1)
            {
                strMessage = "Ảnh";
            }
            else if (mediaType == 2)
            {
                strMessage = "Flash";
            }
            else if(mediaType==3)
            {
                strMessage = "Video";  
            }

            return strMessage;
        }
       
    }
}
